<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>


<script type="text/javascript">
	function departmentTree_onNodeClick(event, treeId, treeNode) {
		// alert(treeNode.treenodePath);
		//alert(	JSON.stringify(treeNode));

		userGrid.search({
			"field" : "treenode_path",
			"op" : "bw",
			"data" : treeNode.treenodePath
		});
	}
</script>

<div class="container_0 clearfix">
	 
		<div id="dvFrameMainNav" class="frame-main-nav" style="overflow: auto">
			<isperp:tree id="departmentTree" modal="false">
				<isperp:async enable="true" autoParam="'id'"
					otherParam="{asyncLoad:1}" url="app/department/getTree">
				</isperp:async>
				<isperp:callback onClick="departmentTree_onNodeClick">
				</isperp:callback>
			</isperp:tree>
		</div>
		<div id="mainContent"
			class="frame-main-cont frame-main-cont-first" role="main">
			<div id="dvContainer">
				<isperp:grid url="customer/user/listDetail" gridId="userGrid"
					altRows="true" gridTitle="${pageTitle}" pager="userPager"
					cusFormatterActions="true" cusEditUrl="customer/user/edit"
					cusViewUrl="customer/user/view" autoload="false"
					ondbClickRowEvent="userGrid.edit(rowid);"
					cusDeleteUrl="customer/user/delete"
					excelExportUrl="customer/user/excelExport">
					<jsp:attribute name="toolbar">
				<isperp:treeMenu id="userMenu" targetGridId="userGrid">
				<isperp:async enable="true" autoParam="" otherParam="[]"
								url="customer/user/userStatusMenu"></isperp:async>
				<isperp:callback onClick="userMenuTree_onNodeClick"
								onAsyncSuccess="userMenuTree_onNodeClickFirst();">
				</isperp:callback>
				</isperp:treeMenu>
			<isperp:toolbar id="userToolbar">
				<isperp:button id="userCreate" icon="icon-plus" text="新增用户"
								cssClass="nui-mainbtn" onclick="userGrid.create();"></isperp:button>
				<isperp:button id="userEdit" icon="icon-download" text="导出到Excel"
								onclick="userGrid.excelExport();"></isperp:button>
			</isperp:toolbar>
			</jsp:attribute>
					<jsp:attribute name="searchbar">
					<table class="search-table">
						<tbody>
							<tr>
								 
								<td align="right">姓名：</td>
								<td><input type="text" field="name" op="cn">
								</td>
								<td align="right">系统帐号：</td>
								<td><input type="text" field="account_id" op="cn">
								</td>
									<td align="right">邮件：</td>
								<td><input type="text" field="email" op="cn">
								</td>
							</tr>
							<tr>
								<td align="right">职务：</td>
								<td><input type="text" field="title" op="cn">
								</td>
								<td align="right">手机：</td>
								<td><input type="text" field="mobile" op="cn">
								</td>
								<td align="right">电话：</td>
								<td><input type="text" field="tel" op="cn">
								</td>
							</tr>
						</tbody>
					</table> 
				</jsp:attribute>
					<jsp:body>
				<isperp:column name="id" title="id" hidden="true"></isperp:column>
				<isperp:column name="openid" title="openid" hidden="true"></isperp:column>
				<isperp:column name="sex" title="性别" width="50" hidden="true">
				</isperp:column>
				<isperp:column name="name" title="名称" width="100"
							isFormatterFun="true"
							formatter="return nameFormatter(cellvalue,rowObject);">
				</isperp:column>
				<isperp:column name="type" title="类型" width="50">
				</isperp:column>
				<isperp:column name="title" title="职务" width="80">
				</isperp:column>
				<isperp:column name="tel" title="电话" width="80">
				</isperp:column>
				<isperp:column name="mobile" title="手机" width="80">
				</isperp:column>
				<isperp:column name="email" title="邮件" width="120">
				</isperp:column>
				 
			</jsp:body>

				</isperp:grid>

				<isperp:operate code="CUS_USER"></isperp:operate>
			</div>
		</div>

	 
</div>
<script type="text/javascript">
	function nameFormatter(cellvalue, rowObject) {
		var result = "";
		var openid = rowObject.openid;
		var sex = rowObject.sex;
		if (openid != null && openid != undefined) {
			result = "<img src='img/wechat/chat.png' alt='来自微信注册' width='20px' height='20px'>";
		}

		if (sex == '男')
			result += "<img src='img/icons/packs/fugue/24x24/user-business.png'>" + cellvalue;
		else
			result += "<img src='img/icons/packs/fugue/24x24/user-female.png'>" + cellvalue;

		return result;
	}
</script>

<style>
<!--
.fixed {
	position: fixed;
}

#dvFrameMainNav{overflow: auto}
-->
</style>
<script type="text/javascript">
	var getScrollY = function() {
		 scrOfY = 0;
		    if( typeof( window.pageYOffset ) == "number" ) {
		        scrOfY = window.pageYOffset;
		    } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		        scrOfY = document.body.scrollTop;
		    } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		        scrOfY = document.documentElement.scrollTop;
		    }
		    return scrOfY;

	}

	var pos_fixed_start_y = 120;
	var pos_fixed_stop_y = $(document).height() - $(window).height() - 150;
	$(window).scroll(function() {
 
		var y = getScrollY();
		
		if (y == 0) {
			$("#dvFrameMainNav").css({
				height : 'auto'
			});
		}
		var nav = $('#dvFrameMainNav');
		if (y >= pos_fixed_start_y && y <= pos_fixed_stop_y) {
			nav.addClass('fixed');
			resetTagTreeHeight();
		} else if (y > pos_fixed_stop_y) {
			nav.addClass('fixed');
			resetTagTreeHeight2();
		} else {
			nav.removeClass('fixed');
		}
	});

	var resetTagTreeHeight = function() {
		var tt = $("#dvFrameMainNav");
		var height = $(window).height();
		tt.css({
			height : height - 20
		});
	};

	var resetTagTreeHeight2 = function() {
		var tt = $("#dvFrameMainNav");
		var height = $(window).height();
		tt.css({
			height : height - 20
		});
	};

	resetTagTreeHeight2();
</script>
